/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.support.cservice;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.os.AsyncTask;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.qihoo.gamecenter.sdk.common.i.s;
import com.qihoo.gamecenter.sdk.support.d.a;

public class RepliedListItemView extends LinearLayout {
    private Context a;
    private TextView b;
    private TextView c;
    private ImageView d;
    private FrameLayout e;
    private LinearLayout f;
    private a g;
    private c h;
    private a i;
    private int j = -1;

    public RepliedListItemView(Context paramContext) {
        super(paramContext);
        this.a = paramContext;
        setOrientation(1);
        b();
    }

    private void b() {
        this.g = a.a(this.a);
        this.b = new TextView(this.a);
        this.b.setSingleLine();
        this.b.setGravity(17);
        this.b.setTextColor(-3355444);
        addView(this.b, generateDefaultLayoutParams());
        this.e = new FrameLayout(this.a);
        addView(this.e, generateDefaultLayoutParams());
        this.f = new LinearLayout(this.a);
        this.e.addView(this.f, new FrameLayout.LayoutParams(-2, -2));
        this.d = new ImageView(this.a);
        this.d.setScaleType(ImageView.ScaleType.FIT_XY);
        this.d.setImageDrawable(this.g.a(1073741844));
        this.f.addView(this.d, new LinearLayout.LayoutParams(s.b(this.a, 30.0F), s.b(this.a, 30.0F)));
        this.c = new TextView(this.a);
        this.c.setTextColor(-16777216);
        this.c.setGravity(16);
        this.c.setTextSize(1, s.a(this.a, 13.3F));
        this.f.setOrientation(0);
        this.f.addView(this.c, new LinearLayout.LayoutParams(-2, -2));
    }

    public RepliedListItemView a(c paramc) {
        this.h = paramc;
        this.b.setText(paramc.f);
        this.c.setText(paramc.g);
        FrameLayout.LayoutParams localLayoutParams = (FrameLayout.LayoutParams) this.f.getLayoutParams();
        if (this.j != paramc.c) {
            if (paramc.c == 1) {
                this.e.setPadding(s.b(this.a, 20.0F), 0, s.b(this.a, 20.0F), 0);
                this.c.setBackgroundDrawable(this.g.a(-1073741824));
                localLayoutParams.gravity = 5;
                this.c.setPadding(s.b(this.a, 10.0F), s.b(this.a, 5.0F), s.b(this.a, 17.0F), s.b(this.a, 5.0F));
                this.d.setVisibility(8);
            }
            else {
                this.e.setPadding(s.b(this.a, 20.0F), 0, s.b(this.a, 20.0F), 0);
                this.c.setBackgroundDrawable(this.g.a(-1073741823));
                localLayoutParams.gravity = 3;
                this.c.setPadding(s.b(this.a, 17.0F), s.b(this.a, 5.0F), s.b(this.a, 10.0F), s.b(this.a, 5.0F));
                this.d.setVisibility(0);
            }
            this.j = paramc.c;
        }
        if (paramc.d) {
            if (this.i == null) {
                this.i = new a(this.a);
                this.g.a(this.i, -1073741786);
                this.i.setPadding(3, 2, 3, 4);
                this.i.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            }
            else {
                this.i.a();
                ViewParent localViewParent = this.i.getParent();
                if ((localViewParent != null) && (localViewParent instanceof ViewGroup))
                    ((ViewGroup) localViewParent).removeView(this.i);
            }
            this.f.addView(this.i, new LinearLayout.LayoutParams(s.b(this.a, 60.0F), s.b(this.a, 60.0F)));
            a();
        }
        else if (this.i != null) {
            this.f.removeView(this.i);
            this.i.a();
        }
        return this;
    }

    public void a() {
        if ((this.i == null) || (!(this.h.d)) || (a.a(this.i)))
            return;
        this.i.a(this.h.e);
    }

    private class a extends ImageView {
        private AsyncTask b;
        private Bitmap c;
        private boolean d = false;

        public a(Context paramContext) {
            super(paramContext);
        }

        public void a(String paramString) {
            if (this.b != null) {
                this.b.cancel(true);
                this.b = null;
            }
            this.b = new AsyncTask() {
                protected Bitmap a(String[] paramArrayOfString) {
                    BitmapFactory.Options localOptions = new BitmapFactory.Options();
                    localOptions.inJustDecodeBounds = true;
                    BitmapFactory.decodeFile(paramArrayOfString[0], localOptions);
                    int i = s.b(RepliedListItemView.a.b(RepliedListItemView.a.this), 80.0F);
                    int j = localOptions.outWidth * i / localOptions.outHeight;
                    localOptions.inSampleSize = (localOptions.outHeight / i);
                    localOptions.outWidth = j;
                    localOptions.outHeight = i;
                    localOptions.inJustDecodeBounds = false;
                    localOptions.inPurgeable = true;
                    localOptions.inInputShareable = true;
                    return BitmapFactory.decodeFile(paramArrayOfString[0], localOptions);
                }

                protected void a(Bitmap paramBitmap) {
                    Bitmap localBitmap = paramBitmap;
                    RepliedListItemView.a.this.setImageBitmap(localBitmap);
                    RepliedListItemView.a.this.setVisibility(0);
                    RepliedListItemView.a.a(RepliedListItemView.a.this, true);
                    if ((RepliedListItemView.a.c(RepliedListItemView.a.this) != null)
                            && (!(RepliedListItemView.a.c(RepliedListItemView.a.this).isRecycled()))) {
                        RepliedListItemView.a.c(RepliedListItemView.a.this).recycle();
                        RepliedListItemView.a.a(RepliedListItemView.a.this, null);
                    }
                    RepliedListItemView.a.a(RepliedListItemView.a.this, localBitmap);
                }
            };
            this.b.execute(new String[] { paramString });
        }

        public void a() {
            if (this.b != null) {
                this.b.cancel(true);
                this.b = null;
            }
            setVisibility(4);
            this.d = false;
            if (this.c == null)
                return;
            this.c = null;
        }
    }
}